import 'package:json_annotation/json_annotation.dart';

part 'book.g.dart';

@JsonSerializable()

class Book {
  int id;
  String name;
  String type;
  String subjectName;
  String publishName;
  String publishShortName;
  String gradeName;

  Book(
      {this.id,
        this.name,
        this.type,
        this.subjectName,
        this.publishName,
        this.publishShortName,
        this.gradeName});

/*  Book.fromJson(Map<String, dynamic> json) {
    id = json['id'] as int;
    name = json['name'];
    type = json['type'];
    subjectName = json['subjectName'];
    publishName = json['publishName'];
    publishShortName = json['publishShortName'];
    gradeName = json['gradeName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['type'] = this.type;
    data['subjectName'] = this.subjectName;
    data['publishName'] = this.publishName;
    data['publishShortName'] = this.publishShortName;
    data['gradeName'] = this.gradeName;
    return data;
  }*/

  //反序列化
  factory Book.fromJson(Map<String, dynamic> json) => _$BookFromJson(json);
//序列化
  Map<String, dynamic> toJson() => _$BookToJson(this);
}